# encoding: utf-8
"""
@author: 夏洛
@QQ: 1972386194
@file: 08-协程.py
"""


import time

def name():
    print('大家好')
    time.sleep(3)
    print('我是夏洛')

def name1():
    print('大家好')
    time.sleep(3)
    print('我是夏洛')

# if __name__ == '__main__':
#     # start = time.time()
#     # name()
#     # name1()
#     # end = time.time() - start
#     # print(end)
#     # 6.000955820083618
#     pass

import asyncio

async def names():
    print('大家好')
    await asyncio.sleep(3)
    print('我是夏洛')

async def name1s():
    print('大家好')
    await asyncio.sleep(3)
    print('我是夏洛')

if __name__ == '__main__':
    start = time.time()
    f = names()
    f1 = name1s()
    tasks = [f,f1]
    # asyncio.run(asyncio.wait(tasks))
    asyncio.get_running_loop(asyncio.wait(tasks))
    end = time.time() - start
    print(end)